// 人员信息查询页
import React, { useEffect } from 'react'
import { connect } from 'dva'
import Findform from '../../lpz/findpeoplemsg/findForm.js'
import Findtable from '../../components/findTable.js'
import { getTableList, reloadPage } from '../../api/UserApi.js'

function Findpeople ({ initTableList, tableList, length }) {
  useEffect(
    initTableList
    , [initTableList])
  const formColumns =
    // 筛选表单的数据
    [
      { ch_name: '单位名称', name: 'unit', type: 'select', option: ['盐田支公司', '龙岗支公司', '罗湖支公司', '车险营业部'] },
      { ch_name: '机构代码', name: 'institution', type: 'input' },
      { ch_name: '证件号', name: 'papersNum', type: 'input' },
      { ch_name: '姓名', name: 'name', type: 'input' },
      { ch_name: '人员代码', name: 'staffCode', type: 'input' },
      { ch_name: '用工形式', name: 'useForm', type: 'select', option: ['总地版员工', '派遣员工', '外包人员', '其他从业人员'] },
      { ch_name: '人员类别', name: 'peopleType', type: 'select', option: ['销售人员', '非销售人员'] },
      { ch_name: '是否转正', name: 'isFull', type: 'select', option: ['是', '否'] },
      { ch_name: '员工职务', name: 'duty', type: 'select', option: ['团队经理', '综合部经理'] },
      { ch_name: '岗位序列', name: 'sequence', type: 'select', option: ['运营支持类', '技术类', '销售类'] },
      { ch_name: '岗位', name: 'workPost', type: 'select', option: ['团队经理', '综合部经理'] },
      { ch_name: '人员状态', name: 'state', type: 'select', option: ['在职', '离职', '退休', '调出', '长期病休', '外派'] },
      { ch_name: '归属部门', name: 'department', type: 'input', option: ['车行一部', '车行二部'] }
    ]
  const btnList = [
    {name: 'submit', ch_name: '查询', type: 'button', color: '#D9463F'}
  ]
  const columns = [
    {
      title: 'ID',
      dataIndex: 'ID',
      width: 60
    },
    {
      title: '机构代码',
      dataIndex: 'institution',
      width: 80
    },
    {
      title: '单位名称',
      dataIndex: 'unit',
      width: 90
    },
    {
      title: '归属部门',
      dataIndex: 'department',
      width: 95
    },
    {
      title: '人员代码',
      dataIndex: 'staffCode',
      width: 80
    },
    {
      title: '证件类型',
      dataIndex: 'papersType',
      width: 80
    },
    {
      title: '证件号',
      dataIndex: 'papersNum',
      width: 80
    },
    {
      title: '姓名',
      dataIndex: 'name',
      width: 80
    },
    {
      title: '人员状态',
      dataIndex: 'state',
      width: 100
    },
    {
      title: '用工形式',
      dataIndex: 'useForm',
      width: 100
    },
    {
      title: '人员类别',
      dataIndex: 'peopleType',
      width: 100
    },
    {
      title: '员工职务',
      dataIndex: 'duty',
      width: 100
    },
    {
      title: '岗位序列',
      dataIndex: 'sequence',
      width: 100
    },
    {
      title: '岗位',
      dataIndex: 'workPost',
      width: 100
    },
    {
      title: '入司时间',
      dataIndex: 'joinTime',
      width: 120
    },
    {
      title: '起薪时间',
      dataIndex: 'moneyTime',
      width: 120
    },
    {
      title: '是否转正',
      dataIndex: 'isFull',
      width: 60
    },
    {
      title: '转正日期',
      dataIndex: 'fullTime',
      width: 120
    },
    {
      title: '调动日期',
      dataIndex: 'removeTime',
      width: 60
    },
    {
      title: '离职日期',
      dataIndex: 'dimission',
      width: 60
    },
    {
      title: '退休日期',
      dataIndex: 'retireTime',
      width: 60
    },
    {
      title: '薪酬停发日期',
      dataIndex: 'stopTime',
      width: 100
    },
    {
      title: '薪酬职级',
      dataIndex: 'moneyRank',
      width: 80
    },
    {
      title: '薪酬档次',
      dataIndex: 'moneyLevel',
      width: 60
    },
    {
      title: '核定薪酬标准',
      dataIndex: 'moneyStandard',
      width: 100
    },
    {
      title: '代发银行名称',
      dataIndex: 'bankName',
      width: 100
    },
    {
      title: '银行账号',
      dataIndex: 'bankNum',
      width: 150
    },
    {
      title: '特殊说明',
      dataIndex: 'remarks',
      width: 80
    }
  ]
  return (
    <div>
      <Findform seachLish={ formColumns } btnList={btnList} />
      <Findtable
        columns={columns}
        tableList={tableList}
        length={length}
        type='global/filtrateListData'
        getTableList={getTableList}
        reloadPage={reloadPage}
        tableLong={2500}
      />
    </div>
  )
}

export default connect(
  (state) => {
    return {
      tableList: state.global.peopleData,
      length: state.global.length
    }
  },
  (dispatch) => ({
    // 初始化表格数据
    initTableList () {
      getTableList(1, 7).then(response => {
        let { data } = response
        if (data.code === 0) {
          dispatch({
            type: 'global/changePeopleData',
            tableList: data.data,
            length: data.length
          })
        }
      })
    }
  })
)(Findpeople)
